﻿using System;
using System.Web.Security;

namespace visinia.web.admin.pages
{
    public partial class EditUser : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["UserName"] == null)
                return;
            MembershipUser user = Membership.GetUser(Request.QueryString["UserName"]);
            if (user != null)
            {
                UserName.Text = user.UserName;
                Email.Text = user.Email;
            }
        }

        protected void UPDATE_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(Email.Text))
                return;
            MembershipUser user = Membership.GetUser(UserName.Text);
            user.Email = Email.Text;
            Membership.UpdateUser(user);
        }

        protected void CANCEL_Click(object sender, EventArgs e)
        {
            Response.Redirect(Request.RawUrl);
        }
    }
}